$(function(){
    getJjzcsp();
});
function getCmsList(channel,pageNumber,pageSize,callback){
    var param = {
        channelId : channel,
        pageNumber:pageNumber,
        pageSize:pageSize
    }
    $.post(window.serviceUrl+"content/getContentList", param, callback, 'json');
}
function getContentDetail(id,callback){
    var param = {
        id : id
    }
    $.post(window.serviceUrl+"content/getContentDetail", param, callback, 'json');
}
function getChannelList(channel,callback){
    var param = {
        channelId : channel
    }
    $.post(window.serviceUrl+"content/getChannelList", param, callback, 'json');
}
function init(){
    getJjContent( window.channelList[tag].zw);

}
function getList(){
    getChannelList(channel,function(data){
        if(data.rtnCode == "000000"){
            var list = data.responseData.records;
            showList(list);
        }
    });
}

function fnGetPage(n){
    getCmsList(channel,n,pageSize,function(data){
        if(data.rtnCode == "000000"){
            var list = data.responseData.records;
            showList(list);
        }
    });
}
function showList(list){
    var content = "";
    $.each(list, function(i, item){
        content += '<a href="detail.html?id='+item.id+'&channel1='+document.title+'">\n' +
            '                            <div class="item">\n' +
            '                                <div class="row">';
        if(isShowImg){
            content +=   ' <div class="col-xs-12 col-sm-4 col-md-3">\n' +
            '                                        <div class="pic">\n' +
            '                                            <div><img\n' +
            '                                                    width="270" height="145" src="'+window.imgUrl+item.typesimgUrl+'"></div>\n' +
            '                                        </div>\n' +
            '                                    </div>';
        }
        content +=  '<div class="col-xs-12 col-sm-8 col-md-9">\n' +
            '                                        <div class="text">\n' +
            '                                            <h3><a href="ztlist.html?zt='+tag+'&childZt='+item.origin+'" target="_blank"' +
            '                                                    >'+item.title+'</a></h3>\n' +
            '                                            <p class="summary" style="">'+item.description+'</p>\n' +
            '                                            <p class="option"><span>'+item.releaseDate+'</span><span></span><span>\n' +
            '                                                    </span>\n' +
            '                                            </p>\n' +
            '                                        </div>\n' +
            '                                    </div>\n' +
            '                                </div>\n' +
            '                            </div>\n' +
            '                        </a>'
    });
    $("#list").html(content);
}
function getBanner(){
    getCmsList(window.channelList[tag].lbt,1,10,function(data){
        if(data.rtnCode == "000000"){
            var list = data.responseData.records;
            var content = "";
            $.each(list, function(i, item){
                content += '<li>\n' +
                    '                    <a href="detail.html?id='+item.id+'&channel1=管理机构" target="_blank" title="">\n' +
                    '                        <img src="'+window.imgUrl+item.typesimgUrl+'" alt="">\n' +
                    '                    </a>\n' +
                    '                    <div class="banner-title"><a href=""></a>\n' +
                    '                    </div>\n' +
                    '                </li>'
            });
            $("#slider").html(content).responsiveSlides({
                auto: true,
                nav: true,
                speed: 500,
                timeout: 4000,
                pager: true,
               // pause: true,
                pauseControls: true,
                namespace: "callbacks"
            });
        }
    });
}

function getJjzcsp(){
    getContentDetail(window.channelList[tag].sp,function(data){
        var item = data.responseData;
        if(data.rtnCode == "000000"){
            var content = '<li>\n' +
                '                                            <div class="item">\n' +
                '                                                <a href="detail.html?id='+item.id+'&channel1='+document.title+'" class="vd-icon"><i\n' +
                '                                                        class="glyphicon glyphicon-play"></i></a>\n' +
                '                                                <a href="detail.html?id='+item.id+'&channel1='+document.title+'" target="_blank" title="'+item.title+'"><img\n' +
                '                                                        width="280" height="188" alt="'+item.title+'"\n' +
                '                                                        src="'+window.imgUrl+item.typesimgUrl+'"' +
                '                                                </a>\n' +
                '                                            </div>\n' +
                '                                        </li>';
            $("#spxcp").html(content);
        }
    });

}

function getJjContent(id){
    getContentDetail(id,function(data){
        if(data.rtnCode == "000000"){
            $("#artitleTitle").html(data.responseData.title);
            document.title = data.responseData.title;
            var reg = new RegExp( '47.112.238.80', "g" );
            $("#articleContent").html(data.responseData.contentHtml.replace( reg , 'www.lyqzh.net' ));
        }
    });

}
function fnGet(sQueryKey,sUrl) {
    sUrl = sUrl?sUrl:window.location.href;
    var aUrlPart = sUrl.split("?");
    var aGet = new Array();
    if (aUrlPart[1]) {
        aGetPair = aUrlPart[1].split("&");
        for (var i = 0; i < aGetPair.length; i++) {
            aTmpArr = aGetPair[i].split("=");
            sKey = aTmpArr[0];
            aGet[sKey] = aTmpArr[1];
        }
    }
    return aGet[sQueryKey];
}